package org.qy137.controller;

import com.qy137.vo.BottomArticleVo;
import io.swagger.annotations.ApiOperation;
import org.qy137.service.BottomArticleService;
import org.qy137.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"bottomarticle"})
public class BottomArticleController {
    @Autowired
    private BottomArticleService bottomArticleService;

    public BottomArticleController() {
    }

    @ApiOperation("分页查询底部文章")
    @GetMapping({"getAllBottomArticle/{page}/{limit}"})
    public CommonResult getAllBottomArticle(@PathVariable Integer page, @PathVariable Integer limit, @RequestBody BottomArticleVo bottomArticleVo) {
        return this.bottomArticleService.getAllBottomArticle(page, limit, bottomArticleVo);
    }

    @ApiOperation("修改底部文章的启动禁用状态")
    @PutMapping({"changeStatus/{id}/{isDisable}"})
    public CommonResult changeStatus(@PathVariable String id, @PathVariable Integer isDisable) {
        return this.bottomArticleService.changeStatus(id, isDisable);
    }

    @ApiOperation("删除底部文章")
    @DeleteMapping({"deleteBottomArticle/{id}"})
    public CommonResult deleteBottomArticle(@PathVariable String id) {
        return this.bottomArticleService.deleteBottomArticle(id);
    }

    @ApiOperation("修改底部文章")
    @PutMapping({"updateBottomArticle"})
    public CommonResult updateBottomArticle(@RequestBody BottomArticleVo bottomArticleVo) {
        return this.bottomArticleService.updateBottomArticle(bottomArticleVo);
    }

    @ApiOperation("添加底部文章")
    @PostMapping({"addBottomArticle"})
    public CommonResult addBottomArticle(@RequestBody BottomArticleVo bottomArticleVo) {
        return this.bottomArticleService.addBottomArticle(bottomArticleVo);
    }
}
